import java.util.Arrays;

public class Test {
    //自动类型转换
    public static void main(String[] args) {
        /*int a = 2;
        byte b = 3;
        byte c = 0;
        c=(byte)(a+b);
        System.out.println(c);*/
        /*long a = 2564;
        int b = 20;
        byte c = 0;
        c=(byte)(a+b);
        System.out.println(c);*/
        byte a = 2;
        byte b = 3;
        byte c = (byte)(a+b);
        System.out.println(c);
    }
    public static boolean jishu(int arr[],int count){
        boolean c = false;
        for(int i = 0;i<arr.length-1;i++){
            if(arr[i]%2!=0){
                count++;
            }else if(count == 3){
                return true;
            }
            else{
                count=0;
            }
        }
        return false;
    }
    public static void main4(String[] args) {
        int [] arr = {1,3,5,8,6,2};
        int count = 0;
        boolean c = jishu(arr,count);
        System.out.println(c);
    }
    public static int [] sum(int [] arr,int taget){
        int left = 0;
        int right = arr.length-1;
        int [] ret = new int []{-1,-1};
        for(int i = 0;i<arr.length-1;i++){
            for(int j = i+1;j<arr.length;j++){
                if(arr[i]+arr[j]==taget){
                    ret[0]=i;
                    ret[1]=j;
                    return ret;

                }
            }
        }
        return ret;

    }
    public static void main3(String[] args) {
        int [] arr = {2,7,9,6};
        int taget = 9;
        int[] c = sum(arr,taget);
        System.out.println(Arrays.toString(c));
    }
    //冒泡排序
    public static void main2(String[] args) {
        int [] arr = {7,4,1,8,5,2,9,6,3};
        int left = 0;
        int right = arr.length-1;
        for (int i = 0; i < arr.length; i++) {
            for(int j = 0;j<arr.length-1-i;j++){
                if(arr[j]>arr[j+1]){
                    int tmp=arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1]=tmp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
    //二分查找
    public static int BinarySearch(int []array,int key){
        int left = 0;
        int right = array.length-1;
        while(left<=right){
            int mid = (left+right)/2;
            if(array[mid] == key) {
                return key;
            } else if (array[mid]<key) {
                left=mid+1;
            }else {
                right=mid-1;
            }
        }
        return -1;
    }
    public static void main1(String[] args) {
        int [] array = {1,4,7,2,5,8,3,6,9};
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));
        int key = 3;
        int c = BinarySearch(array,key);
        System.out.println(c);
    }
}
